<%@page import="java.util.GregorianCalendar"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.sinba.common.business.dto.SellQueryDTO"%>
<%@page import="com.sinba.common.business.service.ISellService"%>
<%@page import="com.sinba.common.business.dto.BuyQueryDTO"%>
<%@page import="com.sinba.common.business.service.IBuyService"%>
<%@page import="com.sinba.common.system.dto.RuleDTO"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="com.sinba.common.utils.TranType"%>
<%@page import="com.sinba.common.user.service.IRegisterUserService"%>
<%@page import="com.sinba.common.user.dto.RegisterUserDTO"%>
<%@page import="com.sinba.common.user.dto.RegisterUserQueryDTO"%>
<%@page import="com.sinba.common.system.dto.SingleGroupReportStatDTO"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="com.sinba.common.system.dto.TransactionRecordDTO"%>
<%@page import="com.sinba.common.system.service.ITransactionRecordService"%>
<%@page import="com.sinba.common.user.dto.AccountDTO"%>
<%@page import="com.sinba.common.user.service.IAccountService"%>
<%@page import="com.sinba.common.news.dto.NewsContentDTO"%>
<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="com.sinba.common.news.dto.NewsQueryDTO"%>
<%@page import="com.sinba.common.news.service.INewsService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.sinba.common.business.service.IMatchService"%>
<%@page import="com.sinba.common.business.dto.MatchQueryDTO"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
	ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	INewsService ns = (INewsService)ac.getBean("newsService");
	NewsQueryDTO queryDTO = new NewsQueryDTO();
	queryDTO.setNewType("WebAffiche");
	queryDTO.setLimit(6);
	PageDTO pagedto = ns.findNewsByCategory(queryDTO);
	
	NewsContentDTO content = ns.findTop1NewsByCategory(new NewsQueryDTO(null,null,null,"NewNotice",null,"WebAffiche"));
	
	ITransactionRecordService transactionRecordService = (ITransactionRecordService)ac.getBean("transactionRecordService");
	Double balance1 = transactionRecordService.findUserBalance(session.getAttribute("loginName").toString(),"Dynamic");
	//Double balance2 = transactionRecordService.findUserBalance(session.getAttribute("loginName").toString(),"Static");
	
	request.setAttribute("balance1",balance1);
	//request.setAttribute("balance2",balance2);
	
	request.setAttribute("pagedto",pagedto);
	request.setAttribute("content",content);
	
	
	NewsQueryDTO queryDTO1 = new NewsQueryDTO();
	queryDTO1.setNewType("WebNews");
	queryDTO1.setLimit(6);
	PageDTO pagedto1 = ns.findNewsByCategory(queryDTO1);
	request.setAttribute("pagedto1",pagedto1);
	
	
	/* TransactionRecordDTO dto = new TransactionRecordDTO();
	dto.setTransactionTypes(TranType.Dynamics);
	dto.setLoginName(session.getAttribute("loginName").toString());
	dto.setInOrExp("income");
	List<SingleGroupReportStatDTO> sgrs =  transactionRecordService.statDtype(dto);
	Double dynamic = 0D;
	Double statics = 0D;
	for(SingleGroupReportStatDTO sdto : sgrs){
		if("Dynamic".equals(sdto.getGroupField())){
			dynamic = sdto.getAggField();
		}else if("Static".equals(sdto.getGroupField())){
			statics = sdto.getAggField();
		}
	}
	//购物积分
	Double shoppingPoints=dynamic+statics;
	request.setAttribute("TotalBonus",shoppingPoints); */
	
	IRegisterUserService registerUserService = (IRegisterUserService)ac.getBean("registerUserService");
	RegisterUserQueryDTO qdto = new RegisterUserQueryDTO();
	qdto.setLoginName((String)session.getAttribute("loginName"));
	RegisterUserDTO registerUserDTO = registerUserService.findRegisterUserByIdOrLoginName(qdto);
	request.setAttribute("registerUserDTO",registerUserDTO);
	
	request.setAttribute("levels",RuleDTO.level.get(registerUserDTO.getRegisterLevel()));
	
	IMatchService matchService = (IMatchService)ac.getBean("matchService");
	
	
	/* //申请提供援助信息
	IBuyService buyService = (IBuyService)ac.getBean("buyService");
	BuyQueryDTO buyQueryDTO = new BuyQueryDTO();
	buyQueryDTO.setStart( 0 );
	buyQueryDTO.setLimit( 10 );
	buyQueryDTO.setBuyUser( (String)session.getAttribute("loginName"));
	buyQueryDTO.setMultipleStatus(new Integer[]{0,1});
	buyQueryDTO.setNotEnd(true);
	PageDTO buyList = buyService.findBuyPage(buyQueryDTO, "asc", "status");
	request.setAttribute("buyList",buyList);
	
	//申请接受援助信息
	ISellService sellService = (ISellService)ac.getBean("sellService");
	SellQueryDTO sellQueryDTO = new SellQueryDTO();
	sellQueryDTO.setStart( 0 );
	sellQueryDTO.setLimit( 10 );
	sellQueryDTO.setNotEnd(true);
	sellQueryDTO.setSellUser( (String)session.getAttribute("loginName"));
	sellQueryDTO.setMultipleStatus(new Integer[]{0,1});
	PageDTO sellList = sellService.findSellPage(sellQueryDTO, "asc", "status");
	request.setAttribute("sellList",sellList);
	 */
/* 	//匹配成功需汇款列表
	MatchQueryDTO matchQueryDTO = new MatchQueryDTO();
	matchQueryDTO.setBuyUser( (String)session.getAttribute("loginName"));
	matchQueryDTO.setStart( 0 );
	matchQueryDTO.setLimit( 1 );
	matchQueryDTO.setMatchStates(new Integer[]{0,3});
	PageDTO buyUserPageDTO = matchService.findMatchPage(matchQueryDTO, null, null);
	request.setAttribute("buyUserPageDTO",buyUserPageDTO);
	
	//匹配成功需收款列表
	MatchQueryDTO matchQueryDTO1 = new MatchQueryDTO(); 
	matchQueryDTO1.setSellUser((String)session.getAttribute("loginName"));
	matchQueryDTO1.setStart( 0 );
	matchQueryDTO1.setLimit( 1 );
	matchQueryDTO1.setMatchStates(new Integer[]{1});
	PageDTO sellUserPageDTO = matchService.findMatchPage(matchQueryDTO1, null, null);
	request.setAttribute("sellUserPageDTO",sellUserPageDTO); */
	
	
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><fmt:message key="i18n.title"/></title>
<link rel="shortcut icon" href="../index/favicon.png" />
<link href="../skin/skin1/css/subPage.css" rel="stylesheet">
<link href="../skin/skin1/css/cssMain.css" rel="stylesheet">
<link rel="stylesheet" href="css/sub_page_main_style.css" />
<script src="js/jquery.min.js"></script>
<script src="../skin/skin1/js/js.js"></script>
<script src="../echarts/echarts.min.js"></script>
<script>
    //* hide all elements & show preloader
    document.documentElement.className += 'js';
</script>
<title><fmt:message key="i18n.indexShowPage"/>-<fmt:message key="i18n.title"/></title>
<script type="text/javascript">
var sessionLoginName = '${session.loginName}';
if(sessionLoginName=='' || sessionLoginName==null){
	alert('System login timeout or not, please login again after this operation(系统超时或未登录，请登录后再进行此操作)!');
	window.parent.location.href="login.jsp";
}
function accountActivate(loginName){
	$('#userActivate_form').html("<input type='hidden' name='pageUrl' value='recommend.jsp' />"+
			"<input type='hidden' name='activeType' value='Myself' />"+
			"<input type='hidden' name='registerUserDTO.loginName' value='"+loginName+"' />");
	if(confirm('Are you sure you want to activate(是否确定要开通)?')){
		$('#acuser_'+loginName).attr("disabled",true);
		$('#userActivate_form').submit();
	}
}

//在网页上输出：今天的日期、星期、现在的时间（动态时钟）
function start()
{
  var today=new Date();
  today.setMinutes(today.getMinutes()-480);
  var year=today.getFullYear();
  var month=today.getMonth()+1;
  var day=today.getDate();
  var hours=today.getHours();
  var minutes=today.getMinutes();
  var seconds=today.getSeconds();
  //如果是单位数字，前面补0
  month=month<10? "0"+month :month;
  day=day<10? "0"+day :day;
  hours=hours<10? "0"+hours :hours;
  minutes=minutes<10? "0"+minutes :minutes;
  seconds=seconds<10? "0"+seconds :seconds;
  //时间信息连成字符串
  var str1=""+day+"   "+month+"   "+year+" ";
  var str2=hours+":"+minutes+":"+seconds;
  //获取id=result的内容
  var obj1=document.getElementById("main_date");
  obj1.innerHTML=str1;
  
  var obj2=document.getElementById("main_time");
  obj2.innerHTML=str2;
  
  
  //延时器
  window.setTimeout("start()",1000);
}

</script>

<style>
#main_links {
    display: block;
    letter-spacing: inherit;
    letter-spacing: 0px;
    background-color: #eee;
    width: 250px;
    padding: 10px;
    -moz-border-radius: 8px 0px 8px 8px;
    border-radius: 8px 0px 8px 8px;
    box-shadow: 0 0 4px #eee;
    font-size: 14px;
    padding-bottom: 1px;
    margin-left: auto;
	margin-right: auto;
}
.timediv {
    text-align: center;
    margin: 0px;
    padding: 0px;
    padding-top: 0px;
    padding-bottom: 10px;
}

</style>
</head>
<body style="background:#ede3d1;" onload="start()">
<div class="account">
	<div class="top"><fmt:message key="i18n.userCenter"/> &gt; <fmt:message key="i18n.firstPage"/>
	 </div>
	<!-- <div class="left"></div> -->
    <div class="right" >
		<div class="timediv" id="main_links" style="width:708px;margin-bottom:15px;height:97px;">
			<div style="float:left;width:49%;border-right:1px solid #ddd;" class="timeBoxLength">
				<br>
				<span id="main_time" class="main_time" data-tz="GMT" style="font-size:35px;color:#000;">15:08:07</span>
				<br><br>
				<span id="main_date" class="main_date" style="font-size:20px;color:#000;position:relative;top:-4px;"></span>
			</div>
			<div style="float:left;position:relative;left:15px;">
				<div style="text-align:left;">
				<br>
					<ul style="position:relative;left:0;padding:0;color:#666;background-image:none;font-size:12px;">
						
						<li><h3>Greenwich Mean Time, GMT </h3></li>
					</ul>
					
					<div style="clear:both;">
					</div>
				</div>
			</div>
		</div>
    	<table id="optionShotcut" style="border: 0px;" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr >
          <td style="padding: 0px;text-align: center;">
 			<input onclick="javascript:window.location.href='buy.jsp'"  type="button" value=" <fmt:message key="i18n.passis"/> " style="cursor: pointer;background-image: url(img/gCons/multi-agents.png); background-repeat: no-repeat;background-position: 10px" class="ty_an_right">
 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 			<%-- <input onclick="javascript:window.location.href='sell.jsp'"  type="button" value=" <fmt:message key="i18n.assis"/> " style="cursor: pointer;background-image: url(img/gCons/world.png); background-repeat: no-repeat;background-position: 10px" class="ty_an_right"> --%>
          </td>
        </tr>
      </table><br/>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" >
      	<tr>
      		<th width="50%" align="center"><fmt:message key="i18n.noticeBroad"/></th>
      		<%-- <th width="50%" align="left"><fmt:message key="i18n.news"/></th> --%>
      	</tr>
      	<tr style="border: 0px;">
      		<td width="50%" align="left" style="padding: 0px;">
      			<c:if test="${pagedto.totalSize >0}">
      			<table width="100%" border="0" cellspacing="0" cellpadding="0" >
				<c:forEach items="${pagedto.data}" var="data" varStatus="status" >
					<tr><td>
					    ${ data.title } <fmt:formatDate type="date" value="${data.createTime}"  pattern="yyyy-MM-dd HH:mm:ss" />
					    <a href="news!newsInfo.action?newsQueryDTO.newId=${data.newId}" style="color: blue;">[<fmt:message key="i18n.look" />]</a>
					</td></tr>
				</c:forEach>
				</table>
				</c:if>
				<c:if test="${pagedto.totalSize <1 }">
				<h4><font style="color:red;"><fmt:message key="i18n.noNoticeInfoTips"/>!</font></h4>
				</c:if>
      		</td>
      		<!-- <td width="50%" align="left">
      		</td> -->
      	</tr>
      </table>
		<h4><fmt:message key="i18n.my.account"/></h4>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th scope="col"><fmt:message key="i18n.myLoginName"/></th>
          <th scope="col"><fmt:message key="i18n.myAssets"/></th>
          <%-- <th scope="col"><fmt:message key="i18n.jtAccount"/></th> --%>
          <%-- <th scope="col"> <fmt:message key="i18n.myAssets"/></th> --%>
          <th scope="col"><fmt:message key="i18n.userlevel" /></th>
          <th scope="col"><fmt:message key="i18n.regTime"/></th>
          <th scope="col"><fmt:message key="titie.openTime"/></th>
          <%-- <th scope="col"><fmt:message key="title.extendLink" /></th> --%>
        </tr>
        <tr>
          <td>${session.loginName}</td>
          <td>
          	<strong> <a href="dynamicAccountDetails.jsp" style="cursor: pointer;color:red;"><fmt:formatNumber value="${balance1}" pattern="#0.0000"/></a></strong>
          </td>
          <%-- <td><strong><a href="st2aticAward.jsp" style="cursor: pointer;color:red;"><fmt:formatNumber value="${balance2}" pattern="#0.0000"/></a></strong></td> --%>
          <%-- <td><strong> <a href="#" style="cursor: pointer;color:red;"><fmt:formatNumber value="${TotalBonus}" pattern="#0.0000"/></a></strong></td> --%>
          <td><fmt:message key="${registerUserDTO.registerLevel }" />(${levels })</td>
          <td style="text-align: center;"><fmt:formatDate value="${registerUserDTO.registerTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
          <td>
          	<fmt:formatDate value="${registerUserDTO.activationTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
            <c:if test="${empty registerUserDTO.activationTime}">
            	<span style="color:red;font-weight: bold;">未激活（如需激活请联系注册时填写的运营中心）</span>
            </c:if>
          </td>
          <!-- <td><a href="#">&nbsp;</a></td> -->
        </tr>
      </table>
      
      <%-- <h4><fmt:message key="title.quickOperation" /></h4>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" >
      	<tr>
      		<th ><fmt:message key="i18n.passis"/><a href="buy.jsp" style="color:red;">[<fmt:message key="i18n.clickComein" />]</a></th>
      		<th><fmt:message key="i18n.assis"/><a href="sell.jsp" style="color:red;">[<fmt:message key="i18n.clickComein" />]</a></th>
      	</tr>
      	<tr><td colspan="4"></tr>
      	<tr>
      		<th ><fmt:message key="i18n.remittanceList"/><a href="matchBuy.jsp?status=0" style="color:red;">&nbsp;&nbsp;(${buyUserPageDTO.totalSize})&nbsp;&nbsp;[<fmt:message key="i18n.clickComein" />]</a></th>
      		<th><fmt:message key="i18n.confirmList"/><a href="matchSell.jsp?status=1" style="color:red;">&nbsp;&nbsp;(${sellUserPageDTO.totalSize})&nbsp;&nbsp;[<fmt:message key="i18n.clickComein" />]</a></th>
      	</tr>
	  </table> --%>
	  <br><br><br>
      <div id="main" style="width: 800px;height:400px;"></div>
     
    </div>
</div>
<script src="js/jquery.min.js"></script>
<script>
$(document).ready(function() {
    //* show all elements & remove preloader
    setTimeout('$("html").removeClass("js")',1000);
});
function logout(){
	if(confirm("Are you sure you want to quit it(确定退出吗)?")){
		window.top.location.href='logout.jsp';
	}
}
</script>
<script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        var option = {
        	    title: {
        	        text: '股价趋势图'
        	    },
        	    tooltip: {
        	        trigger: 'axis'
        	    },
        	    legend: {
        	        data:['指导价','市场价']
        	    },
        	    grid: {
        	        left: '3%',
        	        right: '4%',
        	        bottom: '3%',
        	        containLabel: true
        	    },
        	    toolbox: {
        	        feature: {
        	            saveAsImage: {}
        	        }
        	    },
        	    xAxis: {
        	        type: 'category',
        	        boundaryGap: false,
        	        data: ['16:00','16:20','16:40','17:00','17:20','17:40','18:00']
        	    },
        	    yAxis: {
        	        type: 'value'
        	    },
        	    series: [
        	        {
        	            name:'指导价',
        	            type:'line',
        	            stack: '总量',
        	            data:[0.12, 0.14, 0.16, 0.18, 0.19, 0.20, 0.22]
        	        },
        	        {
        	            name:'市场价',
        	            type:'line',
        	            stack: '总量',
        	            data:[0.1, 0.12, 0.13, 0.13, 0.15, 0.17, 0.18]
        	        }
        	    ]
        	};
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>
</html>